home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’96
/
VideoFolder 1.0a
/
Source
/
MoreFiles 1.4.1
/
MoreDesktopMgr.p
< prev
next >
Wrap
Text File
|
1995-12-21
|
10KB
|
242 lines
UNIT MoreDesktopMgr;
{ Apple Macintosh Developer Technical Support }
{ }
{ A collection of useful high-level Desktop Manager routines. }
{ If the Desktop Manager isn't available, use the Desktop file }
{ for 'read' operations. }
{ }
{ We do more because we can... }
{ }
{ by Jim Luther and Nitin Ganatra, }
{ Apple Developer Technical Support Emeriti }
{ }
{ File: MoreDesktopMgr.p }
{ }
{ Copyright © 1992-1995 Apple Computer, Inc. }
{ All rights reserved. }
{ }
{ You may incorporate this sample code into your applications without }
{ restriction, though the sample code has been provided "AS IS" and the }
{ responsibility for its operation is 100% yours. However, what you are }
{ not permitted to do is to redistribute the source as "DSC Sample Code" }
{ after having made changes. If you're going to re-distribute the source, }
{ we require that you make it clear in the source that the code was }
{ descended from Apple Sample Code, but that you've made changes. }
INTERFACE
USES
Files;
{***************************************************************************}
FUNCTION DTOpen (volName: StringPtr;
vRefNum: Integer;
VAR dtRefNum: Integer;
VAR newDTDatabase: Boolean): OSErr;
{ The DTOpen function opens a volume's desktop database. It returns }
{ the reference number of the desktop database and indicates if the }
{ desktop database was created as a result of this call (if it was }
{ created, then it is empty). }
{ }
{ volName input: A pointer to the name of a mounted volume }
{ or nil. }
{ vRefNum input: Volume specification. }
{ dtRefNum output: The reference number of Desktop Manager's }
{ desktop database on the specified volume. }
{ newDTDatabase output: true if the desktop database was created as a }
{ result of this call and thus empty. }
{ false if the desktop database was already }
{ created, or if it could not be determined if it }
{ was already created. }
{***************************************************************************}
FUNCTION DTGetAPPL (volName: StringPtr;
vRefNum: Integer;
creator: OSType;
VAR applVRefNum: Integer;
VAR applParID: LongInt;
VAR applName: Str255): OSErr;
{ The DTGetAPPL function finds an application (file type 'APPL') with }
{ the specified creator on the specified volume. It first tries to get }
{ the application mapping from the desktop database. If that fails, then }
{ it tries to find an application with the specified creator using }
{ the File Manager's CatSearch routine. If that fails, then it tries to }
{ find an application in the Desktop file. }
{ }
{ volName input: A pointer to the name of a mounted volume }
{ or nil. }
{ vRefNum input: Volume specification. }
{ creator input: The file's creator type. }
{ applVRefNum output: The volume reference number of the volume the }
{ application is on. }
{ applParID output: The parent directory ID of the application. }
{ applName output: The name of the application. }
{***************************************************************************}
FUNCTION FSpDTGetAPPL (volName: StringPtr;
vRefNum: Integer;
creator: OSType;
VAR spec: FSSpec): OSErr;
{ The FSpDTGetAPPL function finds an application (file type 'APPL') with }
{ the specified creator on the specified volume. It first tries to get }
{ the application mapping from the desktop database. If that fails, then }
{ it tries to find an application with the specified creator using }
{ the File Manager's CatSearch routine. If that fails, then it tries to }
{ find an application in the Desktop file. }
{ }
{ volName input: A pointer to the name of a mounted volume }
{ or nil. }
{ vRefNum input: Volume specification. }
{ creator input: The file's creator type. }
{ spec output: FSSpec record containing the application name and }
{ location. }
{***************************************************************************}
FUNCTION DTGetIcon (volName: StringPtr;
vRefNum: Integer;
iconType: Integer;
fileCreator: OSType;
fileType: OSType;
VAR iconHandle: Handle): OSErr;
{ The DTGetIcon function retrieves the specified icon and returns it in }
{ a newly created handle. The icon is retrieves from the Desktop Manager }
{ or if the Desktop Manager is not available, from the Finder's Desktop }
{ file. Your program is responsible for disposing of the handle when it }
{ is done using the icon. }
{ }
{ volName input: A pointer to the name of a mounted volume }
{ or nil. }
{ vRefNum input: Volume specification. }
{ iconType input: The icon type as defined in Files.h. Valid values }
{ are: }
{ kLargeIcon }
{ kLarge4BitIcon }
{ kLarge8BitIcon }
{ kSmallIcon }
{ kSmall4BitIcon }
{ kSmall8BitIcon }
{ fileCreator input: The icon's creator type. }
{ fileType input: The icon's file type. }
{ iconHandle output: A Handle containing the newly created icon. }
{***************************************************************************}
FUNCTION DTSetComment (vRefNum: Integer;
dirID: LongInt;
name: StringPtr;
comment: Str255): OSErr;
{ The DTSetComment function sets a file or directory's Finder comment }
{ field. The volume must support the Desktop Manager because you only }
{ have read access to the Desktop file. }
{ }
{ vRefNum input: Volume specification. }
{ dirID input: Directory ID. }
{ name input: Pointer to object name, or nil when dirID }
{ specifies a directory that's the object. }
{ comment input: The comment to add. Comments are limited to 200 }
{ characters; longer comments are truncated. }
{***************************************************************************}
FUNCTION FSpDTSetComment ({CONST}VAR spec: FSSpec;
comment: Str255): OSErr;
{ The FSpDTSetComment function sets a file or directory's Finder comment }
{ field. The volume must support the Desktop Manager because you only }
{ have read access to the Desktop file. }
{ }
{ spec input: An FSSpec record specifying the file or directory. }
{ comment input: The comment to add. Comments are limited to 200 }
{ characters; longer comments are truncated. }
{***************************************************************************}
FUNCTION DTGetComment (vRefNum: Integer;
dirID: LongInt;
name: StringPtr;
VAR comment: Str255): OSErr;
{ The DTGetComment function gets a file or directory's Finder comment }
{ field (if any) from the Desktop Manager or if the Desktop Manager is }
{ not available, from the Finder's Desktop file. }
{ }
{ vRefNum input: Volume specification. }
{ dirID input: Directory ID. }
{ name input: Pointer to object name, or nil when dirID }
{ specifies a directory that's the object. }
{ comment output: A Str255 where the comment is to be returned. }
{***************************************************************************}
FUNCTION FSpDTGetComment ({CONST}VAR spec: FSSpec;
VAR comment: Str255): OSErr;
{ The FSpDTGetComment function gets a file or directory's Finder comment }
{ field (if any) from the Desktop Manager or if the Desktop Manager is }
{ not available, from the Finder's Desktop file. }
{ }
{ spec input: An FSSpec record specifying the file or directory. }
{ comment output: A Str255 where the comment is to be returned. }
{***************************************************************************}
FUNCTION DTCopyComment (srcVRefNum: Integer;
srcDirID: LongInt;
srcName: StringPtr;
dstVRefNum: Integer;
dstDirID: LongInt;
dstName: StringPtr): OSErr;
{ The DTCopyComment function copies the file or folder comment from the }
{ source to the destination object. The destination volume must support }
{ the Desktop Manager because you only have read access to the Desktop }
{ file. }
{ }
{ srcVRefNum input: Source volume specification. }
{ srcDirID input: Source directory ID. }
{ srcName input: Pointer to source object name, or nil when srcDirID }
{ specifies a directory that's the object. }
{ dstVRefNum input: Destination volume specification. }
{ dstDirID input: Destination directory ID. }
{ dstName input: Pointer to destination object name, or nil when }
{ dstDirID specifies a directory that's the object. }
{***************************************************************************}
FUNCTION FSpDTCopyComment ({CONST}VAR srcSpec: FSSpec;
{CONST}VAR dstSpec: FSSpec): OSErr;
{ The FSpDTCopyComment function copies the desktop database comment from }
{ the source to the destination object. Both the source and the }
{ destination volumes must support the Desktop Manager. }
{ }
{ srcSpec input: An FSSpec record specifying the source object. }
{ dstSpec input: An FSSpec record specifying the destination object. }
{***************************************************************************}
IMPLEMENTATION
END.